package com.aspose.cells.b.a.d;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

public class ze extends zm {
   private boolean a;
   private zl b;

   public ze(String var1, int var2, int var3, int var4) throws IOException {
      this(var1, var2, var3);
   }

   public String h_() {
      return this.b.a();
   }

   public void g_() throws IOException {
      this.b();
      this.a();
   }

   public ze(String var1, boolean var2, boolean var3) throws Exception {
      if (var2 && var3) {
         File var4 = new File(var1);
         if (var4.exists()) {
            var4.delete();
         }
      } else if (!var2 && !var3 && !(new File(var1)).exists()) {
         throw new FileNotFoundException("Can't find read-only file: " + var1);
      }

      this.a = var2;
      this.b = new zl(var1, this.a ? "rw" : "r");
   }

   public ze(String var1, int var2) throws IOException {
      byte var3;
      switch(var2) {
      case 1:
         var3 = 2;
         break;
      case 2:
         var3 = 2;
         break;
      case 3:
         var3 = 1;
         break;
      case 4:
      case 5:
      default:
         var3 = 3;
         break;
      case 6:
         var3 = 3;
      }

      this.a((String)var1, var2, var3);
   }

   private void a(String var1, int var2, int var3) throws IOException {
      if (var1 == null) {
         throw new NullPointerException("File path can't be null.");
      } else if ("".equals(var1)) {
         throw new IllegalArgumentException("File path can't be \"\".");
      } else if (var2 >= 1 && var2 <= 6) {
         if (var3 >= 1 && var3 <= 3) {
            String var4;
            if (var3 == 1) {
               this.a = false;
               var4 = "r";
            } else {
               this.a = true;
               var4 = "rw";
            }

            File var5 = new File(var1);
            if (var5.exists()) {
               if (var2 == 1) {
                  throw new IOException("Can't create new file. File '" + var1 + "' already exist.");
               }

               if (var2 == 2 || var2 == 5) {
                  var5.delete();
               }

               this.b = new zl(var5, var4);
               if (var2 == 6) {
                  this.b.a(this.b.d());
               }
            } else {
               if (var2 == 3 || var2 == 5) {
                  throw new FileNotFoundException("Can't find file: " + var1 + ".");
               }

               this.b = new zl(var5, var4);
            }

         } else {
            throw new IndexOutOfBoundsException("access = " + var3);
         }
      } else {
         throw new IndexOutOfBoundsException("Illegal FileMode: " + var2 + ".");
      }
   }

   public ze(String var1, int var2, int var3) throws IOException {
      this.a(var1, var2, var3);
   }

   public boolean d() {
      return true;
   }

   public boolean e() {
      return true;
   }

   public boolean f() {
      return this.a;
   }

   public long h() throws IOException {
      return this.b.d();
   }

   public long i() throws IOException {
      return this.b.c();
   }

   public void b(long var1) throws IOException {
      this.b.a(var1);
   }

   public void b() throws IOException {
      this.b.e();
   }

   public long a(long var1, int var3) throws IOException {
      switch(var3) {
      case 0:
         this.b.a(var1);
         break;
      case 1:
         this.b.a(this.b.c() + var1);
         break;
      case 2:
         this.b.a(this.b.d() + var1);
         break;
      default:
         throw new IllegalStateException("Unknown SeekOrigin type.");
      }

      return this.b.c();
   }

   public void a() throws IOException {
      this.b.b();
   }

   public void a(long var1) throws IOException {
      this.b.b(var1);
   }

   public int a(byte[] var1, int var2, int var3) throws IOException {
      int var4 = this.b.a(var1, var2, var3);
      return var4 == -1 ? 0 : var4;
   }

   public int c() throws IOException {
      return this.b.f();
   }

   public void b(byte[] var1, int var2, int var3) throws IOException {
      this.b.write(var1, var2, var3);
   }

   public void a(byte var1) throws IOException {
      this.b.write(var1);
   }
}
